#include "InterpolationSolver.h"
#include <iostream>
#include <fstream>

//[题目D要求]A car traveling along a straight road is clocked at a number of points. The data from the observations are given in the following table, where the time is in seconds, the distance is in feet, and the speed is in feet per second.
//(a)Use a Hermite polynomial to predict the position of the car and its speed for t = 10s.
//(b)Use the derivative of the Hermite polynomial to determine whether the car ever exceeds the 55 mi/h (81 feet per second) speed limit.

int main()
{
    std::vector<double> T{0,0,3,3,5,5,8,8,13,13};
    std::vector<double> D_and_S{0,75,225,77,383,80,623,74,993,72};
    Hermite_Formula h(T, D_and_S);
    std::cout << "The car's distance at t = 10s is " << h.solve(10) << " feet" << std::endl;
    std::cout << "The car's speed at t = 10s is " << h.solvediff(10) << " feet/s" << std::endl;

    double max = 0;
    for (int i = 0; i < 100*13; i++)
    {
        if (h.solvediff(i*0.01) > max)
            max = h.solvediff(i*0.01);
    }
    std::cout << "The max speed during the observation is " << max << " feet per second" << std::endl;
    
    return 0;
}
